@model Eqwww.Domain.Models.Identity.UserModel
@inject Eqwww.Config.IAppConfigProvider AppConfigProvider
@inject Eqwww.App.Identity.UserApp UserApp
@inject Eqwww.App.SystemManage.OrganizeApp OrganizeApp

@{
    ViewData["Title"] = "个人信息";
    Layout = "~/Views/Shared/_ManageIndexLayout.cshtml";

    var appConfig=AppConfigProvider.Load();
}

<div class="mdui-container">
    <div class="mdui-row">
        <div class="mdui-col-xs-12 mdui-col-md-6">

            <div class="mdui-typo-title mdui-p-t-4">基本信息</div>
            <div class="mdui-list">
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            @Html.DisplayNameFor(model => model.Avatar)
                        </div>
                        <div class="mdui-list-item-title">
                            <img class="mdui-img-circle" style="width:128px;" src="@Model.Avatar" />
                        </div>

                    </div>
                    <div class="mdui-text-right">
                        <div>
                            <a href="javascript:;" onclick="btn_avatar()" class="mdui-btn mdui-text-color-theme">
                                系统头像
                                <i class="mdui-icon material-icons">arrow_forward</i>
                            </a>
                        </div>
                        @if (appConfig.CanUseCustomAvatar && appConfig.CanEditSelfCustomAvatar)
                        {
                            <div>
                                <a href="javascript:;" onclick="btn_customavatar()" class="mdui-btn mdui-text-color-theme">
                                    自定头像
                                    <i class="mdui-icon material-icons">arrow_forward</i>
                                </a>
                            </div>
                        }
                    </div>
                </div>
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            用户名
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.UserName)
                            @if (Model.UserType == Eqwww.Domain.Models.Identity.UserType.RTX)
                            {<span class="mdui-color-theme">RTX</span>}
                        </div>
                    </div>
                    <div class="mdui-text-right @if(Model.UserType==Eqwww.Domain.Models.Identity.UserType.RTX){ <text>mdui-hidden</text> }">
                        <a href="javascript:;" onclick="btn_changepassword()" class="mdui-btn mdui-text-color-theme">
                            修改密码
                            <i class="mdui-icon material-icons">lock_open</i>
                        </a>
                    </div>
                </div>

                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            姓名
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.RealName)
                        </div>
                    </div>
                    <div class="mdui-text-right">
                        <a href="javascript:;" onclick="btn_changerealname()" class="mdui-btn mdui-text-color-theme">
                            修改
                            <i class="mdui-icon material-icons">arrow_forward</i>
                        </a>
                    </div>
                </div>
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            电子邮箱
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.Email)
                        </div>
                    </div>
                    <div class="mdui-text-right">
                        <a href="javascript:;" onclick="btn_changeemail()" class="mdui-btn mdui-text-color-theme">
                            修改
                            <i class="mdui-icon material-icons">arrow_forward</i>
                        </a>
                    </div>
                </div>
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            联系方式
                        </div>
                        <div class="mdui-list-item-title">
                            @Html.DisplayFor(model => model.Contact)
                        </div>
                    </div>
                    <div class="mdui-text-right">
                        <a href="javascript:;" onclick="btn_changeContact()" class="mdui-btn mdui-text-color-theme">
                            修改
                            <i class="mdui-icon material-icons">arrow_forward</i>
                        </a>
                    </div>
                </div>
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            角色列表
                        </div>
                        @{
                            var myRoles = UserApp.GetRolesByPrincipal(User);
                        }
                        @if (myRoles.Count() <= 0)
                        {
                            <div class="mdui-list-item-title">
                                <span class="mdui-text-color-theme-accent">未设置</span>
                            </div>
                        }
                        else
                        {
                            foreach (var role in myRoles)
                            {
                                <div class="mdui-list-item-title">
                                    @role.ShowName
                                </div>
                            }
                        }


                    </div>
                    <div class="mdui-text-right">
                        <a href="javascript:;" onclick="btn_mypermissions()" class="mdui-btn mdui-text-color-theme">
                            查看我的权限
                            <i class="mdui-icon material-icons">help_outline</i>
                        </a>
                    </div>
                </div>
                <div class="mdui-list-item mdui-ripple">
                    <div class="mdui-list-item-content">
                        <div class="mdui-list-item-text">
                            岗位列表
                        </div>
                        @{
                            var myPosts = UserApp.GetPostsByPrincipal(User);
                            if (myPosts != null && myPosts.Count() > 0)
                            {
                                foreach (var item in myPosts)
                                {
                                    var completePath = OrganizeApp.GetAncestorNamesString(item.OrganizeId) + "/" + item.Name;
                                    <div class="mdui-list-item-title">
                                        @completePath
                                    </div>
                                }
                            }
                            else
                            {
                                <div class="mdui-list-item-title">
                                    <span class="mdui-text-color-theme-accent">未设置</span>
                                </div>
                            }
                        }

                    </div>

                </div>


            </div>
            <div class="mdui-divider"></div>

            


        <div class="mdui-col-xs-12 mdui-col-md-6">
            
        </div>
    </div>
</div>

@section Scripts{
    <script>
        function btn_avatar(){
            $.modalOpen({
                id: 'Avatar',
                title: '系统头像',
                url: '/SystemManage/MyAccount/Avatar',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_changeContact() {
            $.modalOpen({
                id: 'Avatar',
                title: '修改联系方式',
                url: '/SystemManage/MyAccount/ChangeContact',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_customavatar(){
            $.modalOpen({
                id: 'Avatar',
                title: '系统头像',
                url: '/SystemManage/MyAccount/CustomAvatar',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_changepassword()
        {
            $.modalOpen({
                id: 'Avatar',
                title: '修改密码',
                url: '/SystemManage/MyAccount/ChangePassword',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_changerealname()
        {
            $.modalOpen({
                id: 'ChangeRealName',
                title: '修改姓名',
                url: '/SystemManage/MyAccount/ChangeRealName',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_changeemail(){
            $.modalOpen({
                id: 'ChangeEmail',
                title: '修改Email',
                url: '/SystemManage/MyAccount/ChangeEmail',
                width: '100%',
                height: '100%',
                callBack: function (iframeId) {
                    var index = top.layer.getFrameIndex(window.name);
                    top.frames[iframeId].submitForm(index);
                }
            });
        }

        function btn_mypermissions(){
            $.modalOpen({
                id: 'MyPermissions',
                title: '我的权限',
                url: '/SystemManage/MyAccount/MyPermissions',
                width: '100%',
                height: '100%',
                isback: true,
                hideConfirmBtn: true,
                btn:null
            });
        }
    </script>
}

